package com.yiren.dbaa.module.help_center.view.fragment;

import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.yiren.dbaa.R;
import com.yiren.dbaa.currency.fragment.LazyLoadFragment;
import com.yiren.dbaa.module.help_center.bean.ToolkitBean;
import com.yiren.dbaa.module.help_center.contract.ToolkitContract;
import com.yiren.dbaa.module.help_center.presenter.ToolkitPresenter;
import com.yiren.dbaa.module.help_center.view.ToolkitAdapter;

import java.util.List;

import butterknife.BindView;

/**
 * @author lwb
 * @date :2022/7/28 17:11
 * @description: 工具包fragment
 */
public class ToolkitFragment extends LazyLoadFragment implements ToolkitContract.View {

    @BindView(R.id.ll_no_data)
    LinearLayout llNoData;
    @BindView(R.id.iv_tip)
    ImageView ivTip;
    @BindView(R.id.tv_tips)
    TextView tvTips;
    @BindView(R.id.lv_toolkit)
    ListView lvToolkit;

    private ToolkitContract.Presenter toolkitPresenter;

    @Override
    protected int setContentView() {
        return R.layout.fragment_toolkit;
    }

    @Override
    protected void init() {
        toolkitPresenter = new ToolkitPresenter(getActivity());
        toolkitPresenter.loadToolkits(this);
        ivTip.setImageResource(R.mipmap.network_no);
        tvTips.setText("加载失败，请连接网络后重试");
    }

    @Override
    public void showToolkit(List<ToolkitBean> toolkitBeanList) {
        if (toolkitBeanList.size() == 0) {
            llNoData.setVisibility(View.VISIBLE);
            lvToolkit.setVisibility(View.GONE);
        } else {
            llNoData.setVisibility(View.GONE);
            lvToolkit.setVisibility(View.VISIBLE);
            ToolkitAdapter toolkitAdapter = new ToolkitAdapter(getActivity(), toolkitBeanList);
            lvToolkit.setAdapter(toolkitAdapter);
        }
    }

    @Override
    public void showProgress(String len) {

    }

    @Override
    public void downSuccess() {

    }
}
